<?php

// Init owncloud

require_once(OC_App::getAppPath('resumes') . "/lib/resume.php");
require_once(OC_App::getAppPath('resumes') . "/lib/helper.php");
require_once(OC_App::getAppPath('resumes') . "/lib/tag.php");

OCP\JSON::callCheck();
$companyid = 0;
if(!OC_User::isLoggedIn()) {
   $app = PFactory::getApplication(); 
   $companyid = $app->getUserState('resumeshare_companyid', 0); 
   if(!$companyid) {
      echo '您需要先登录'; 
      exit;
   }
} else {
   if (PFactory::isJobseekerUser()) {
      echo '您不是企业用户';
      exit();
   } else {
      $user = PFactory::getMasterUser();
      $companyid = $user->id;
   }
}

$resumeid = JRequest::getInt('resumeid', 0);

$model = new PResumesModelResume();
$resume = $model->getResumeJobDetail($resumeid, $companyid);

if(empty($resume)) {
   echo '没有详细信息';
   exit;
}

$resumeTags_string_span = '';

$tagmodel = new PResumesModelTag();
$resumeTags = $tagmodel->getResumeTags($resumeid, $companyid);

$searchUrl = JRequest::getString('searchurl', OCP\Util::linkToRoute('resumes_search'));

if(!empty($resumeTags)) {
   foreach($resumeTags as $resumeTag) {
      list($href, $selected) = PResumesHelper::getSearchItemHref($searchUrl, 'keyword', rawurlencode($resumeTag->name));
      $resumeTags_string_span .= "<span><a href=" . $href . ">" . $resumeTag->name . "</a></span>";
   }
}

?>

<div class="clearfix" style="padding-top:10px;">
   <?php
   $educationInfo = array();
   if (!empty($resume->highest_education_school_name)) {
      $educationInfo[] = $resume->highest_education_school_name;
   }
   if (!empty($resume->highest_education_major_name)) {
      $educationInfo[] = $resume->highest_education_major_name;
   }
   $educationInfoHtml = '';
   if (!empty($educationInfo)) {
      $educationInfoHtml = implode('&nbsp;&nbsp;|&nbsp;&nbsp;', $educationInfo);
   }
   
   $workInfo = array();
   if (!empty($resume->latest_workexp_company_name)) {
      $workInfo[] = $resume->latest_workexp_company_name;
   }
   if (!empty($resume->latest_workexp_job_spec)) {
      $workInfo[] = $resume->latest_workexp_job_spec;
   }
   if (!empty($resume->latest_workexp_job_title)) {
      $workInfo[] = $resume->latest_workexp_job_title;
   }
   if (!empty($resume->latest_workexp_exp)) {
      $workInfo[] = $resume->latest_workexp_exp;
   }
   $workInfoHtml = '';
   if (!empty($workInfo)) {
      $workInfoHtml = implode('&nbsp;&nbsp;|&nbsp;&nbsp;', $workInfo);
   }
   
   ?>
   <div class="pull-left resumejob"><b>院校专业：</b><?php echo $educationInfoHtml ? $educationInfoHtml : "---"; ?></div>
   <div class="pull-left resumejob"><b>最近工作：</b><?php echo $workInfoHtml ? $workInfoHtml : "---"; ?></div>
</div>
<div class="resume_hrtaget">
<?php if(!empty($resumeTags_string_span)):?>
   <b>标签：</b>
   <?=$resumeTags_string_span?>
<?php endif; ?>
</div>

<?php if(0): ?>
<div class="hr_scoreshow">
   <b style="font-weight:normal;">评分：</b>
   <span class="scoregray"><em style="width:<?=isset($resume->commentstar) ? $resume->commentstar*20 : 0;?>%;"></em></span>
   <span class="red"><?=isset($resume->commenttext) ? $resume->commenttext : '';?></span>
</div>
<?php endif; ?>



